package com.zhonghui.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger配置：
 * @description: 访问地址：http://localhost:8081/swagger-ui.html
 * @author: FL
 * @create: 2024 2024/5/30 23:20
 */
@Configuration // 配置类
@EnableSwagger2 // 开启 swagger2 的自动配置
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        // 创建一个 swagger 的 bean 实例
        return new Docket(DocumentationType.SWAGGER_2)
                // 配置基本信息
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhonghui.controller"))
                .paths(PathSelectors.any()).build()
                ;
    }

    /**
     * 基本信息设置
     */
    private ApiInfo apiInfo() {
        Contact contact = new Contact(
                "FL",
                "https://blog.csdn.net/sq91fra?type=lately",
                "777777777@163.com");
        return new ApiInfoBuilder()
                .title("易商城-接口文档")
                .description("众里寻他千百度，慕然回首那人却在灯火阑珊处")
                .termsOfServiceUrl("https://blog.csdn.net/sq91fra?type=lately")
                .version("1.0")
                .contact(contact)
                .build();
    }


}

